<template>
	<view class="">
		<common-title :title="titleContent" @clickLeft="backToUpPage" @clickRight="editCoupleName"></common-title>
		<view class="change-name"  :class="{active : isHeightLight}">
			<input class="change-name-input" v-model="coupleName" @focus="highLightBottom" @blur="highLightBottom"/>
		</view>
	</view>
</template>

<script setup>
	import { ref } from "vue";
	import { onLoad } from '@dcloudio/uni-app'
	import { editCoupleInfo } from "../../../../utils/apiMine";
	//================================common-title=========================================
	//标题内容
	const titleContent = ref({
		left:'',
		midst:'修改组合名',
		right:'保存'
	});
	
	//返回
	const backToUpPage = () => {
		uni.navigateBack();
	};
	//保存修改
	const editCoupleName = async () => {
		// console.log(coupleName.value);
		await editCoupleInfo({'couplesName' : coupleName.value}).then((res) => {
			// console.log(value==='200');
			if (res === '200') {
				uni.showToast({
					title:'保存成功'
				})
			}
		}).finally(() => {
			uni.redirectTo({
				url:'/pages/mine/other_set/couple-set'
			});
		})
	}
	//---------------------------------修改名字---------------------------------------------
	const coupleName = ref('');
	onLoad((options) => {
		// 从 options 中获取 coupleName
		coupleName.value = options.couplesName ? decodeURIComponent(options.couplesName) : '';
		// console.log(coupleName.value);
	})
	const isHeightLight = ref(false);
	const highLightBottom = () => {
		isHeightLight.value = !isHeightLight.value;
		// console.log(isHeightLight.value);
	}
</script>

<style lang="scss" scoped>
	.change-name{
		width: 690rpx;
		margin: 30rpx;
		// background-color: aqua;
		border-bottom: 1px solid #676767;
		&.active {
			border-bottom: 2px solid #87CEEB;
			
		}
		.change-name-input{
			padding: 20rpx;
			font-size: 36rpx;
		}
	}
</style>